package com.lmb.controller;

import com.lmb.bean.Subsidies;
import com.lmb.mapper.SubsidiesDao;
import com.lmb.service.SubsidiesService;
import com.lmb.util.Page;
import com.lmb.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/subsidies")
public class SubsidiesController {
    @Autowired
    SubsidiesDao subsidiesDao;
    @Autowired
    SubsidiesService subsidiesService;
    @PostMapping
    public Result add(@RequestBody Subsidies subsidies)
    {
        Object obj=subsidiesService.add(subsidies);
        return Result.success("添加保存成功",obj);
    }
    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj=subsidiesService.del(id);
        return Result.success("删除成功",obj);
    }
    @PutMapping
    public Result edit(@RequestBody Subsidies subsidies){
        Object obj=subsidiesService.edit(subsidies);
        return Result.success("信息修改成功",obj);
    }
    @GetMapping("all")
    public Result all( Subsidies subsidies){
        Object obj=subsidiesService.all(subsidies);
        return Result.success(obj);
    }
    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=subsidiesService.one(id);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, Subsidies subsidies){
        subsidiesService.page(page,subsidies);
        return Result.success(page);
    }
}
